package com.example.demo.common;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ling
 * Date: 2023-12-06
 * Time: 20:45
 */
@Component
public class AjaxResult {
    public static HashMap<String,Object> success(Object data) {
        HashMap<String,Object> result = new HashMap<>();
        result.put("code",200);
        result.put("msg","");
        result.put("data",data);
        return result;
    }


    public static HashMap<String,Object> success(Object data,String msg) {
        HashMap<String,Object> result = new HashMap<>();
        result.put("code",200);
        result.put("msg",msg);
        result.put("data",data);
        return result;
    }



    public static HashMap<String,Object> fail(int code,String msg) {
        HashMap<String,Object> result = new HashMap<>();
        result.put("code",code);
        result.put("msg",msg);
        result.put("data","");
        return result;

    }
}
